package com.qf.servlet;

import com.qf.pojo.User;
import com.qf.service.AdminService;
import com.qf.service.impl.AdminServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 管理员查询所有用户
 */
@WebServlet("/findAllUser")
public class FindAllServlet extends HttpServlet {


    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //调用AdminService
        AdminService adminService = new AdminServiceImpl() ;
        List<User> list  =adminService.getAllUser() ;

        //直接将list存储request域对象中
        request.setAttribute("list",list) ;
        //请求转发到
        request.getRequestDispatcher("/admin/admin_index/user_list.jsp").forward(request,response);

    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
}
